package com.itheima.demo02interface;

import java.util.Arrays;
import java.util.Comparator;
import java.util.function.Supplier;

public class Demo02Supplier {
    public static void main(String[] args) {
        getMax(() ->{
            int[] arr = {11, 33, 66, 88, 55};
            Arrays.sort(arr); // 默认升序排序
            return arr[arr.length - 1];
        });

        getMin(() -> {
            Integer[] arr = {11, 33, 66, 88, 55};
            Arrays.sort(arr, Comparator.reverseOrder()); // 降序排序
            return arr[arr.length - 1];
        });
    }

    public static void getMax(Supplier<Integer> supplier){
        int max = supplier.get();
        System.out.println("max = " + max);
    }

    public static void getMin(Supplier<Integer> supplier){
        int min = supplier.get();
        System.out.println("min = " + min);
    }

}
